'''
Created on Mar 21, 2016

@author: JimmyMo
'''
import dispatcher_logpumper
import dispatcher_mibrefresher
import dispatcher_collector

from config_reader_file import ConfigReaderFile

import logging
import schedule
import time
logging.basicConfig(level=logging.DEBUG,
                format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                datefmt='%a, %d %b %Y %H:%M:%S',
                filename='dispatcher.log',
                filemode='w')
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)

config_reader = ConfigReaderFile()

collector = dispatcher_collector.DispatcherCollector(config_reader)
collector.start()
# collector.dispatch()

log_pumper = dispatcher_logpumper.DispatcherLogPumper(config_reader)
log_pumper.start()


# log_pumper.dispatch()
# 
# mib_refresher = dispatcher_mibrefresher.DispatcherMibRefresher(config_reader)
# mib_refresher.start()
# mib_refresher.dispatch()

schedule.run_all(delay_seconds=1);
while 1:
    schedule.run_pending()
    time.sleep(1)

# collector.join()
# log_pumper.join()


# mib_refresher.join()


